<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="${ctx}/bootstrap/jquery-1.9.1.min.js"></script>
    <link rel="stylesheet" href="${ctx}/css/index_work.css">
</head>
<body>
<form action="${ctx}/save.do" method="post" enctype="multipart/form-data">
    <input type="hidden" name="did" value="${dianpu.did}">
    <br/>店铺名称<input type="text" name="dname" value="${dianpu.dname}">
    <br/>创建时间<input type="date" name="create_date" value="${dianpu.create_date}">
    <br/>图片<input type="file" name="file">
    <img src="${dianpu.img}" style="width: 30px;height: 30px">
    <div id="shops">

    </div>
    <br/> <input type="submit" value="保存">
</form>
<script>
    $.post("${ctx}/getShops.do",function (res) {
        for (let x in res) {
            $("#shops").append('<input type="checkbox" name="sids" value="'+res[x].sid+'">'+res[x].sname);
        }
        <c:forEach items="${dianpu.shopList}" var="var">
            $('[name="sids"][value="${var.sid}"]').prop("checked",true);
        </c:forEach>
    })
</script>
</body>
</html>
